//
//  TestSelectSongCell.m
//  CloudTest
//
//  Created by 张帅 on 2020/7/23.
//  Copyright © 2020 张帅. All rights reserved.
//

#import "TestSelectSongCell.h"
@interface TestSelectSongCell ()
@property(nonatomic,strong)UITextField * textFieled;
@property(nonatomic,strong)UIImageView * arrow_imageView;
@property(nonatomic,strong)UIView * textBaseView;
@end
@implementation TestSelectSongCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self =  [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self uiSet];
    }
    return self;
}

- (void)uiSet {
   
     
     self.textBaseView = [[UIView alloc] initWithFrame:CGRectZero];
     self.textBaseView.layer.cornerRadius = 6;
     self.textBaseView.layer.masksToBounds = YES;
     self.textBaseView.backgroundColor = color(@"#F5F5F5");
     [self.contentView addSubview:self.textBaseView];
      [self.textBaseView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(10);
            make.left.mas_equalTo(20);
            make.right.mas_equalTo(self.contentView.mas_right).offset(-20);
            make.height.mas_equalTo(50);
     }];
     
     UITapGestureRecognizer * tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapClicked:)];
     [self.textBaseView addGestureRecognizer:tap];
    
    
     self.arrow_imageView = [UIFactory create_ImageView_ImageName:@"向下箭头"];
     self.arrow_imageView.highlightedImage = UIImageMake(@"向上箭头");
     [self.textBaseView addSubview:self.arrow_imageView];
     [self.arrow_imageView mas_makeConstraints:^(MASConstraintMaker *make) {
         make.centerY.mas_equalTo(self.textBaseView);
         make.right.mas_equalTo(self.textBaseView.mas_right).offset(-16);
         make.width.mas_equalTo(24);
         make.height.mas_equalTo(24);
     }];
     
    self.textFieled = [[UITextField alloc] initWithFrame:CGRectZero];
    self.textFieled.font = [UIFont systemFontOfSize:16];
    self.textFieled.userInteractionEnabled = NO;
    self.textFieled.backgroundColor = color(@"#F5F5F5");
    [self.textBaseView addSubview:self.textFieled];
    [self.textFieled mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(0);
        make.left.mas_equalTo(12);
        make.right.mas_equalTo(self.arrow_imageView.mas_left).offset(-12);
        make.height.mas_equalTo(self.textBaseView);
    }];
}
-(void)setModel:(GroupVos *)model {
    _model = model;
    self.arrow_imageView.highlighted = NO;
    self.textFieled.placeholder = _model.name;
    if (_model.selected) {
        self.textFieled.text = _model.song_name;//选中的歌曲名
    } else {
        self.textFieled.text = @"";
    } 
}
- (void)tapClicked:(UIGestureRecognizer *)tap {
    self.arrow_imageView.highlighted = YES;
    if (self.selected_block) {
        self.selected_block(_indexPath);
    }
}
@end
